<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>后台管理--菜单列表</title>
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet"/>
    <link href="${ctxStatic}/ligeruilib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
    <link href="${ctxStatic}/css/kpiui.css" rel="stylesheet"/>
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="${ctxStatic}/js/common.js" type="text/javascript"></script>
    <script src="${ctxStatic}/img/canvg2.js" type="text/javascript"></script>
    <script src="${ctxStatic}/img/html2canvas-0.4.1.js" type="text/javascript"></script>
    <script src="${ctxStatic}/img/canvg2.js" type="text/javascript"></script>
    <script src="${ctxStatic}/img/jspdf.min.js" type="text/javascript"></script>


    <style>
        .pdf > table {
            width: 100%;
            font-size: .938em;
            border-collapse: collapse; /*边框会合并为一个单一的边框*/
        }

        .pdf th {
            text-align: left;
            padding: .5em .5em;
            font-weight: bold;
            background: #66677c;
            color: #fff;
        }

        .pdf td {
            padding: .5em .5em;
            border-bottom: solid 1px #ccc;
        }

        .pdf table, .pdf table tr th, .pdf table tr td {
            border: 1px solid #0094ff;
        }

        /*设置边框的*/
    </style>

</head>
<body>


<div class="serchcontent" style="margin:10px">
    <div class="search" style="    margin-top: 10px;   margin-left: 30px">
        <div class="layui-form">
            <table>
                <tr>
                    <td class="td_select">
                        <select id="year" placeholder="年份" lay-filter="year">
                            <option value="2025">2025年</option>
                            <option value="2024">2024年</option>
                            <option value="2023">2023年</option>
                            <option value="2022">2022年</option>
                            <option value="2021">2021年</option>
                            <option value="2020">2020年</option>
                            <option value="2019">2019年</option>
                            <option value="2018">2018年</option>
                            <option value="2017">2017年</option>
                        </select>

                    </td>
                    <td style="width: 80px; text-align: right;color:#ffffff">季度：</td>
                    <td style="width:150px">
                        <select name="quarter" id="quarter" lay-filter="quarter">
                            <option value="1">第一季度</option>
                            <option value="2">第二季度</option>
                            <option value="3">第三季度</option>
                            <option value="4">第四季度</option>
                        </select>
                        <input type="hidden" id="hidyear" value="${year}"/>
                        <input type="hidden" id="hidquarter" value="${quarter}">
                        <input type="hidden" id="hidorgid" value="">
                        <input type="hidden" id="hidusername" value="${username}">
                        <input type="hidden" id="hidorgname" value="${orgname}">
                    </td>
                    <td>
                        <input type="button" class="button" value="查询" onclick="search()"/>
                        <button class="button" id="pdfbutton" style="display: none" onclick="createPdf()">重新生成公示</button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>

<div class="content" style="margin-left: 20px">

    <table class="layui-table fc-view-container" lay-data="" lay-filter="attbmhzlist" id="attbmhzlist">
    </table>
</div>
<div class="bottom_tab" id="bottom_btns" style="display: block;">
    <input type="button" id="passbtn" class="button" value="通过" onclick="ok()"/>
    <input type="button" id="retbtn" class="button" value="驳回" onclick="reject()"/>
</div>

<div id="table" class="pdf" style="display: none">
    <div class="orgname" style="text-align: center"></div>
    <table id="tableData">
        <thead>
        <tr>
            <th colspan="9">扣减情况</th>
            <th colspan="4">增加情况</th>
        </tr>
        <tr>
            <th >序号</th>
            <th >姓名</th>
            <th >部门</th>
            <th >身份证号</th>
            <th >原因</th>
            <th id="month1"></th>
            <th id="month2"></th>
            <th id="month3"></th>
            <th >合计</th>
            <th >姓名</th>
            <th >身份证号</th>
            <th >原因</th>
            <th >金额</th>
        </tr>
        </thead>
    </table>

</div>
<!--  <div id="list" class="list" lay-filter="list"></div>-->


</div>


</div>
</body>
<script>
    var _table;
    var _form;
    var hidtablehight;
    $(function () {

        initForm();
        $('#year').val(new Date().getFullYear());
        var hidquarter = $("#hidquarter").val();
        $('#quarter').val(hidquarter);
        $("#year").val($("#hidyear").val());
        var str = hidquarter + '季';
        _form.render('select');

        getData(function (data) {
            // console.log(data.status);
            if(data.status == 4 || data.status == 2){
                $("#pdfbutton").show();
                $("#passbtn").hide();
                $("#retbtn").hide();
            }else if (data.status == 1){
                $('#pdfbutton').hide();
                $("#passbtn").show();
                $("#retbtn").show();
            }else{
                $('#pdfbutton').hide();
                $("#passbtn").hide();
                $("#retbtn").hide();
            }

            window.datas = data;
            $("#hidorgid").val(data.orgid)//记录处理的部门
            initTable(data.year, data.month, data.orgid, data.orgsummaryid, $('#realname').val());
            testData($('#quarter').val());
        });
    })

    function initTabletitle() {
        var quarter =   $('#quarter').val();
        var month1 ="一月";
        var month2 ="二月";
        var month3 ="三月";
        if(quarter ==2){month1="四月";month2="五月";month3="六月"}
        if(quarter ==3){month1="七月";month2="八月";month3="九月"}
        if(quarter ==4){month1="十月";month2="十一月";month3="十二月"}

        $("#month1").text(month1);
        $("#month2").text(month2);
        $("#month3").text(month3);

        var html = "房山公安分局" + $('#hidorgname').val();

        html += $('#year').val() + "年第" + quarter + "季度工作性津贴"
        $('.orgname').html(html)

        console.log(html);
    }

    function initForm() {
        layui.use('form', function () {
            form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功


            form.render();
            _form = form;
        });
    }


    function testData(quarter) {
        var data = window.datas;
        $.ajax({
            type: "POST",
            url: "get_work_dept_list",
            data: {
                year: data.year ? data.year : '1990',
                month: data.month?data.month : '12',
                orgid: data.orgid?data.orgid : '-1',
                quarter: quarter,
                realname: data.realname,
                page: 1,
                limit: 1000
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')').data;
                for (var i = 0; i < data.length; i++) {
                    var tr = "<tr><td>" + (i + 1) + "</td>";
                    tr += "<td>" + data[i].realname + "</td>";
                    tr += "<td>" + data[i].orgname + "</td>";
                    tr += "<td>" + data[i].cardno + "</td>";
                    tr += "<td>" + (data[i].downreason  == null ? '' : data[i].downreason)+ "</td>";
                    tr += "<td>" + (data[i].workpernum1  == null ? '' : data[i].workpernum1)+ "</td>";
                    tr += "<td>" + (data[i].workpernum2  == null ? '' : data[i].workpernum2)+ "</td>";
                    tr += "<td>" + (data[i].workpernum3  == null ? '' : data[i].workpernum3)+ "</td>";
                    tr += "<td>" + (data[i].workpernumsum  == null ? '' : data[i].workpernumsum)+ "</td>";
                    tr += "<td>" + data[i].realname + "</td>";
                    tr += "<td>" + data[i].cardno + "</td>";
                    tr += "<td>" + (data[i].upreason  == null ? '' : data[i].upreason)+ "</td>";
                    tr += "<td>" + (data[i].upmoney  == null ? '' : data[i].upmoney)+ "</td></tr>";
                    $('#tableData').append(tr);
                }
                //hidtablehight =  data.length * 70;
            },
            complete: function (XHR) {
                top.mylayui.closeAll('loading');
            },
            error: function () {

            }
        });
    }


    function initTable(year, month, orgid, orgsummaryid, realname) {
        var quarter =  $("#quarter").val();
        var month1 ="一月";
        var month2 ="二月";
        var month3 ="三月";
        if(quarter ==2){month1="四月";month2="五月";month3="六月"}
        if(quarter ==3){month1="七月";month2="八月";month3="九月"}
        if(quarter ==4){month1="十月";month2="十一月";month3="十二月"}
        layui.use('table', function () {
            table = layui.table;
            table.init('attbmhzlist', {
                height: $(window).height() - 100
                , url: 'get_work_dept_list' // 数据接口
                , page: true // 开启分页
                , limit: 40
                , id: 'attbmhzlist'
                , limits: [20, 40, 80, 100]
                ,cols: [
                    [
                        {title : '扣减情况',align : 'center',colspan: 8}
                        , {title : '增加情况',align : 'center',colspan: 4}
                    ],
                    [ // 表头
                        {field : 'realname',title : '姓名',width : 80,align : 'center'}
                        , {field:'orgname',title : '部门', width:120,align:'center'}
                        , {field : 'cardno',title : '身份证号',width : 120,align : 'center'}
                        , {field : 'downreason',title : '原因',width : 120,align : 'center',edit:'text'}
                        , {field : 'workpernum1',title : ''+month1+'',width : 80,align : 'center'}
                        , {field : 'workpernum2',title : ''+month2+'',width : 80,align : 'center'}
                        , {field : 'workpernum3',title : ''+month3+'',width : 80,align : 'center'}
                        , {field : 'workpernumsum',title : '加班补贴合计',width : 180,align : 'center'}
                        , {field : 'realname',title : '姓名',width : 80,align : 'center'}
                        , {field : 'cardno',title : '身份证号',width : 120,align : 'center'}
                        , {field : 'upreason',title : '原因',width : 120,align : 'center'}
                        , {field : 'upmoney',title : '金额',width : 120,align : 'center'}
                        , {field : 'status',title : '状态',width : 120,align : 'center'}
                    ]
                ]
                , method: "post"
                , request: {
                    type: 'post'
                }
                , where: {
                    year: year ? year : '1990',
                    month: month? month : '12',
                    orgid: orgid? orgid : '-1',
                    quarter: quarter,
                    realname: realname
                }
                , done: function (res, page, count) {
                    var dataarr = res.data;
                    if(dataarr.length != 0){
                    // console.log(dataarr[0].orgname);
                    $("#hidorgname").val(dataarr[0].orgname);
                    }
                    $("[data-field='status']").children().each(function (index) {
                        if (index > 0) {
                            var text = $(this).text();
                            switch (text) {
                                case null:
                                    $(this).text("未填报");
                                    break;
                                case '':
                                    $(this).text("未填报");
                                    break;
                                case '0':
                                    $(this).text("填报");
                                    break;
                                case '1':
                                    $(this).text("提交");
                                    break;
                                case '2':
                                    $(this).text("归档");
                                    break;
                                case '3':
                                    $(this).text("驳回");
                                    break;
                                case '4':
                                    $(this).text("通过");
                                    break;
                            }
                        }
                    })


                    $("[data-field='sfqq']").children().each(function (index) {
                        if (index > 0) {
                            var text = $(this).text();
                            if (text == "0") {
                                $(this).text("否");
                            }
                            else {
                                $(this).text("是");
                            }
                        }
                    })
                }
            });
            _table = table;
        })
    }

    function getData(callback) {
        $.ajax({
            type: "POST",
            url: "get_org_summary_work_list",
            data: {
                year: $('#year').val(),
                quarter: $('#quarter').val(),
                orgid :$("#hidorgid").val()
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')').data;
                if (data.length > 0) {
                    window.orgsummaryid = data[0].orgsummaryid;
                    callback && callback(data[0]);


                } else {
                    callback && callback({});

                }

            },
            complete: function (XHR) {
                top.mylayui.closeAll('loading');
            },
            error: function () {

            }
        });

    }


    function search() {
        getData(function (data) {
            if(data.status == 4 || data.status == 2){
                $("#pdfbutton").show();
                $("#passbtn").hide();
                $("#retbtn").hide();

            }else if (data.status == 1){
                $('#pdfbutton').hide()
                $("#passbtn").show();
                $("#retbtn").show();
            }else{
                $('#pdfbutton').hide();
                $("#passbtn").hide();
                $("#retbtn").hide();
            }

            window.datas = data;
            $("#hidorgid").val(data.orgid)//记录处理的部门，每次查询，修改更新
            var quarter =  $("#quarter").val();
            var month1 ="一月";
            var month2 ="二月";
            var month3 ="三月";
            if(quarter ==2){month1="四月";month2="五月";month3="六月"}
            if(quarter ==3){month1="七月";month2="八月";month3="九月"}
            if(quarter ==4){month1="十月";month2="十一月";month3="十二月"}

            _table.reload('attbmhzlist', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,cols: [
                    [
                        {title : '扣减情况',align : 'center',colspan: 8}
                        , {title : '增加情况',align : 'center',colspan: 4}
                    ],
                    [ // 表头
                        {field : 'realname',title : '姓名',width : 80,align : 'center'}
                        , {field:'orgname',title : '部门', width:120,align:'center'}
                        , {field : 'cardno',title : '身份证号',width : 120,align : 'center'}
                        , {field : 'downreason',title : '原因',width : 120,align : 'center',edit:'text'}
                        , {field : 'workpernum1',title : ''+month1+'',width : 80,align : 'center'}
                        , {field : 'workpernum2',title : ''+month2+'',width : 80,align : 'center'}
                        , {field : 'workpernum3',title : ''+month3+'',width : 80,align : 'center'}
                        , {field : 'workpernumsum',title : '加班补贴合计',width : 180,align : 'center'}
                        , {field : 'realname',title : '姓名',width : 80,align : 'center'}
                        , {field : 'cardno',title : '身份证号',width : 120,align : 'center'}
                        , {field : 'upreason',title : '原因',width : 120,align : 'center'}
                        , {field : 'upmoney',title : '金额',width : 120,align : 'center'}
                        , {field : 'status',title : '状态',width : 120,align : 'center'}
                    ]
                ]
                ,where: {
                    year: data.year ? data.year : '1990',
                    month: data.month,
                    quarter: quarter,
                    orgid: data.orgid,
                    orgsummaryid: data.orgsummaryid,
                    realname: $('#realname').val()
                }
            });
            testData(quarter);
        })
    }

    function ok() {
        updateStatus(4, function () {
            createPdf();
            layer.msg('审核成功', {icon: 1})

        }, function () {
            layer.msg('审核失败', {icon: 0})

        })
    }

    function createPdf() {
        initTabletitle();//PDF生成前，重新生成标题

        var data = window.datas;
        var userName =$("#hidusername").val();
        var nowtime =data.year+ "年"+data.quarter+"季";
        var targetDom = $("#table");
        hidtablehight= targetDom.height();

        watermark({ watermark_txt: userName+"  "+nowtime });

        //把需要导出的pdf内容clone一份，这样对它进行转换、微调等操作时才不会影响原来界面
        var copyDom = targetDom.clone();
        //新的div宽高跟原来一样，高度设置成自适应，这样才能完整显示节点中的所有内容（比如说表格滚动条中的内容）
        copyDom.width(targetDom.width() + "px");
        copyDom.height(targetDom.height() + "px");
        copyDom.css('display', 'block');
        copyDom.css({
            "background-color": "white",
            "position": "absolute",
            "top": "600px",
            "z-index": "-1",
            "height": targetDom.height()
        });
        $('body').append(copyDom);
        svg2canvas(copyDom);
        html2canvas(copyDom, {
            onrendered: function (canvas) {
                var imgData = canvas.toDataURL('image/jpeg');
                var img = new Image();
                img.src = imgData;

                // img.src = 'http://127.0.0.1:8080/1.pdf';
                //根据图片的尺寸设置pdf的规格，要在图片加载成功时执行，之所以要*0.225是因为比例问题
                img.onload = function () {
                    //此处需要注意，pdf横置和竖置两个属性，需要根据宽高的比例来调整，不然会出现显示不完全的问题
                    if (this.width > this.height) {
                        var doc = new jsPDF('l', 'mm', [this.width * 0.225,
                            this.height * 0.225
                        ]);
                    } else {
                        var doc = new jsPDF('p', 'mm', [this.width * 0.225,
                            this.height * 0.225
                        ]);
                    }
                    doc.addImage(imgData, 'jpeg', 0, 0, this.width * 0.225,
                        this.height * 0.225);
                    //根据下载保存成不同的文件名
                    if (data.year) {
                        $.ajax({
                            type: "POST",
                            url: "createPDF",
                            data: {
                                file: doc.output("datauristring"),
                                year: data.year,
                                month: data.month,
                                orgid: data.orgid,

                            },
                            beforeSend: function (XHR) {

                            },
                            success: function (data) {


                            },
                            complete: function (XHR) {

                            },
                            error: function () {

                            }
                        });
                    }


                    // console.log(doc.output("datauristring"))
                    // doc.save('pdf_' + new Date().getTime() + '.pdf');
                };
                //删除复制出来的div
                copyDom.remove();
            },
            background: "#fff",

            //这里给生成的图片默认背景，不然的话，如果你的html根节点没设置背景的话，会用黑色填充。
            allowTaint: true //避免一些不识别的图片干扰，默认为false，遇到不识别的图片干扰则会停止处理html2canvas
        });
    }

    function svg2canvas(targetElem) {
        var svgElem = targetElem.find('svg');
        svgElem.each(function (index, node) {
            var parentNode = node.parentNode;
            //由于现在的IE不支持直接对svg标签node取内容，所以需要在当前标签外面套一层div，通过外层div的innerHTML属性来获取
            var tempNode = document.createElement('div');
            tempNode.appendChild(node);
            var svg = tempNode.innerHTML;
            var canvas = document.createElement('canvas');
            //转换
            canvg(canvas, svg);
            parentNode.appendChild(canvas);
        });
    }

    function watermark(settings) {
        //默认设置
        var defaultSettings={
            watermark_txt:"text",
            watermark_x:20,//水印起始位置x轴坐标
            watermark_y:20,//水印起始位置Y轴坐标
            watermark_rows:0,//水印行数
            watermark_cols:20,//水印列数
            watermark_x_space:100,//水印x轴间隔
            watermark_y_space:50,//水印y轴间隔
            watermark_color:'#aaa',//水印字体颜色
            watermark_alpha:0.6,//水印透明度
            watermark_fontsize:'15px',//水印字体大小
            watermark_font:'微软雅黑',//水印字体
            watermark_width:210,//水印宽度
            watermark_height:80,//水印长度
            watermark_angle:15//水印倾斜度数
        };
        //采用配置项替换默认值，作用类似jquery.extend
        if(arguments.length===1&&typeof arguments[0] ==="object" )
        {
            var src=arguments[0]||{};
            for(key in src)
            {
                if(src[key]&&defaultSettings[key]&&src[key]===defaultSettings[key])
                    continue;
                else if(src[key])
                    defaultSettings[key]=src[key];
            }
        }

        var oTemp = document.createDocumentFragment();

        //获取页面最大宽度
        var page_width = Math.max(document.body.scrollWidth,document.body.clientWidth);
        var cutWidth = page_width*0.0150;
        var page_width=page_width-cutWidth;
        //获取页面最大高度
        var page_height = parseInt(hidtablehight);
        console.log("页面高度："+page_height);
        // var page_height = Math.max(document.body.scrollHeight,document.body.clientHeight)+450;
        // var page_height = document.body.scrollHeight+document.body.scrollTop;
        //如果将水印列数设置为0，或水印列数设置过大，超过页面最大宽度，则重新计算水印列数和水印x轴间隔
        if (defaultSettings.watermark_cols == 0 || (parseInt(defaultSettings.watermark_x + defaultSettings.watermark_width *defaultSettings.watermark_cols + defaultSettings.watermark_x_space * (defaultSettings.watermark_cols - 1)) > page_width)) {
            defaultSettings.watermark_cols = parseInt((page_width-defaultSettings.watermark_x+defaultSettings.watermark_x_space) / (defaultSettings.watermark_width + defaultSettings.watermark_x_space));
            defaultSettings.watermark_x_space = parseInt((page_width - defaultSettings.watermark_x - defaultSettings.watermark_width * defaultSettings.watermark_cols) / (defaultSettings.watermark_cols - 1));
        }
        //如果将水印行数设置为0，或水印行数设置过大，超过页面最大长度，则重新计算水印行数和水印y轴间隔
        if (defaultSettings.watermark_rows == 0 || (parseInt(defaultSettings.watermark_y + defaultSettings.watermark_height * defaultSettings.watermark_rows + defaultSettings.watermark_y_space * (defaultSettings.watermark_rows - 1)) > page_height)) {
            defaultSettings.watermark_rows = parseInt((defaultSettings.watermark_y_space + page_height - defaultSettings.watermark_y) / (defaultSettings.watermark_height + defaultSettings.watermark_y_space));
            defaultSettings.watermark_y_space = parseInt(((page_height - defaultSettings.watermark_y) - defaultSettings.watermark_height * defaultSettings.watermark_rows) / (defaultSettings.watermark_rows - 1));
        }
        var x;
        var y;
        for (var i = 0; i < defaultSettings.watermark_rows; i++) {
            y = defaultSettings.watermark_y + (defaultSettings.watermark_y_space + defaultSettings.watermark_height) * i;
            for (var j = 0; j < defaultSettings.watermark_cols; j++) {
                x = defaultSettings.watermark_x + (defaultSettings.watermark_width + defaultSettings.watermark_x_space) * j;

                var mask_div = document.createElement('div');
                mask_div.id = 'mask_div' + i + j;
                mask_div.className = 'mask_div';
                mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
                //设置水印div倾斜显示
                mask_div.style.webkitTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.MozTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.msTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.OTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.transform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
                mask_div.style.visibility = "";
                mask_div.style.position = "absolute";
                mask_div.style.left = x + 'px';
                mask_div.style.top = y + 'px';
                mask_div.style.overflow = "hidden";
                mask_div.style.zIndex = "9999";
                mask_div.style.pointerEvents='none';//pointer-events:none  让水印不遮挡页面的点击事件
                //mask_div.style.border="solid #eee 1px";
                mask_div.style.opacity = defaultSettings.watermark_alpha;
                mask_div.style.fontSize = defaultSettings.watermark_fontsize;
                mask_div.style.fontFamily = defaultSettings.watermark_font;
                mask_div.style.color = defaultSettings.watermark_color;
                mask_div.style.textAlign = "center";
                mask_div.style.width = defaultSettings.watermark_width + 'px';
                mask_div.style.height = defaultSettings.watermark_height + 'px';
                mask_div.style.display = "block";
                oTemp.appendChild(mask_div);
            };
        };
        // $("#table").appendChild(oTemp);
        document.getElementById("table").appendChild(oTemp);
    }


    function reject() {
        updateStatus(0, function () {
            layer.msg('驳回成功', {icon: 1})
        }, function () {
            layer.msg('驳回失败', {icon: 0})

        });
    }

    function updateStatus(status, success, fail) {
        var year = $("#year").val();
        var quarter = $("#quarter").val();
        var orgid =$("#hidorgid").val();

        $.ajax({
            type: "POST",
            url: "update_work_pay_status",
            data: {
                year:year,
                quarter:quarter,
                orgid: orgid,
                status: status
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.code == 200) {
                    success && success();
                    search();

                } else {
                    fail && fail();

                }

            },
            complete: function (XHR) {
                top.mylayui.closeAll('loading');
            },
            error: function () {

            }
        });
    }
</script>
</html>
